<template>
  <div>
    <el-dialog :visible="timingVis" title="定时报告" width="600px" @close="handleCloseTiming">
      <el-form ref="formRef" :model="formData" label-width="120px" :rules="formRules">
        <el-form-item label="报告名称：" prop="name">
          <el-input size="mini" style="width: 80%" v-model="formData.name"></el-input>
        </el-form-item>
        <el-form-item label="频率：" prop="frequency">
          <el-radio-group v-model="formData.frequency">
            <el-radio :label="0">单次</el-radio>
            <el-radio :label="1">每天</el-radio>
            <el-radio :label="2">每周</el-radio>
            <el-radio :label="3">每月</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="导出时间：" prop="exportTime">
          <el-date-picker
            size="mini"
            style="width: 80%"
            v-model="formData.exportTime"
            type="date"
            placeholder="选择日期"
          >
          </el-date-picker>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="handleConfirm" type="primary" size="mini">确认</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: {
    timingVis: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      formData: {
        name: '',
        frequency: '',
        exportTime: '',
      },
      formRules: {
        name: [{ required: true, message: '请填写', trigger: 'blur' }],
        frequency: [{ required: true, message: '请填写', trigger: 'blur' }],
        exportTime: [{ required: true, message: '请填写', trigger: 'blur' }],
      },
    }
  },
  methods: {
    async handleConfirm() {
      try {
        this.$message.warning('功能开发中~')
        await this.$refs.formRef.validate()
        this.handleCloseTiming()
      } catch {
        this.$message.warning('请填写完成！')
      }
    },
    handleCloseTiming() {
      this.$emit('handleCloseTiming')
      this.$refs.formRef.resetFields()
    },
  },
}
</script>

<style lang="scss" scoped></style>
